<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>登录-AI智能客服系统</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        .main-body {
			display: flex;
			justify-content: center;
			align-items: center;
			height: 100vh;
		}
        .login-main {width:428px;
			background: #fff;
			box-shadow: 0 1px 30px 0 rgba(171,184,202,.19), 0 10px 15px 0 rgba(227,231,237,.2);
		}
		.login-main h2{
			font-weight: 300;
			font-size: 22px;
			text-align: center;
			margin-top: 20px;
		}
        .login-main .login-bottom {width:428px;background:#fff;padding-bottom:53px;}
        .login-main .login-bottom .center {width:288px;margin:0 auto;padding-top:40px;padding-bottom:15px;position:relative;}
        body {background: url(/static/seller/images/background_new.jpg) no-repeat;font-size:12px;}

        html {height:100%;}

        @media screen and (max-width:428px) {.login-main {width:360px !important;}
            .login-main .login-top {width:360px !important;}
            .login-main .login-bottom {width:360px !important;}
        }
    </style>
</head>
<body>
<div class="main-body">
    <div class="login-main">
        <h2>客服系统商家后台登录</h2>
        <form class="layui-form login-bottom">

            <div class="center">
				
				  <div class="layui-form-item" pane>
				      <input type="text" name="username" lay-verify="required" placeholder="请输入登录账号" autocomplete="off" class="layui-input">
				  </div>
				
				<div class="layui-form-item" pane>
				    <input type="text" name="password" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
				</div>
				
				<div class="layui-form-item" pane>
				    <input maxlength="4" type="text" style="width: 125px;" class="layui-input-inline layui-input" name="captcha" lay-verify="required" placeholder="请输入验证码" autocomplete="off" >
					<img style="width: 150px;height: 40px;" id="refreshCaptcha" class="validateImg"  src="{:captcha_src()}" onclick="this.src='{:captcha_src()}?t='+Math.random();" title="不清楚? 点击换一个">
				</div>
				
				<div class="layui-form-item">
					<button class="layui-btn" style="width: 100%;" lay-submit="" lay-filter="login">立即登录</button>
				</div>

            </div>

        </form>
    </div>
</div>
<script type="text/javascript" src="__STATIC__/layui/layui.js"></script>
<script>
    layui.use(['form','jquery'], function () {
        var $ = layui.jquery,
            form = layui.form,
            layer = layui.layer;

        form.on('submit(login)', function(data) {
            if (data.field.username == '') {
                layer.msg('用户名不能为空');
                return false;
            }
            if (data.field.password == '') {
                layer.msg('密码不能为空');
                return false;
            }
            if (data.field.captcha == '') {
                layer.msg('验证码不能为空');
                return false;
            }
            layer.load();
            $.ajax({
                type: "POST",
                url: "/seller/login/doLogin",
                data: data.field,
                success: function (res) {
                    layer.closeAll('loading');
                    if (res.code==0){
                        layer.msg(res.msg,{icon:1,time:1000},function () {
                            location.href = res.data;
                        })
                    } else {
                        layer.msg(res.msg,{icon:2,time:1000},function () {
                            initCode();
                        })
                    }
                }
            });
            return false;
        });

        function initCode() {
            $('#refreshCaptcha').attr("src","{:captcha_src()}?t=" + Math.random());
        }

        // 登录过期的时候，跳出ifram框架
        if (top.location != self.location) top.location = self.location;

        $('.bind-password').on('click', function () {
            if ($(this).hasClass('icon-5')) {
                $(this).removeClass('icon-5');
                $("input[name='password']").attr('type', 'password');
            } else {
                $(this).addClass('icon-5');
                $("input[name='password']").attr('type', 'text');
            }
        });
    });
</script>
</body>
</html>